//
//  SecondViewController.m
//  项目A --半糖
//
//  Created by romana on 16/5/16.
//  Copyright © 2016年 romana. All rights reserved.
//

#import "SecondViewController.h"
#import "SecondHeadView.h"
#import "SecondLeftViewController.h"
#import "SecondRightViewController.h"

@interface SecondViewController ()

@property(nonatomic,strong)SecondLeftViewController *SLVC;
@property(nonatomic,strong)SecondRightViewController *SRVC;


@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
//    self.navigationController.navigationBar.translucent = NO;
//    
//    SecondHeadView *secondHV = [[SecondHeadView alloc ]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 440)];
//    secondHV.backgroundColor = [UIColor whiteColor];
//    [self.view addSubview:secondHV];
    
    self.SLVC = [[SecondLeftViewController alloc] init];
    [self addChildViewController:self.SLVC];
    
    self.SRVC = [[SecondRightViewController alloc] init];
    [self addChildViewController:self.SRVC];
    [self.view addSubview:self.SRVC.view];
    [self.view addSubview:self.SLVC.view];

    
    UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"清单",@"单品"]];
    segment.frame = CGRectMake(0, 0, 100, 30);
    segment.tintColor = [UIColor redColor];
  //  segment.layer.borderColor = [[UIColor whiteColor]CGColor];;
    self.navigationItem.titleView = segment;
    [segment addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    
    segment.selectedSegmentIndex = 0;
    
    
    
    
}

-(void)segmentAction:(UISegmentedControl *)segment{
    
    if (segment.selectedSegmentIndex == 0) {
        [self.view bringSubviewToFront:self.SLVC.view];
    }else{
        
        [self.view bringSubviewToFront:self.SRVC.view];
        
    }
    
    
}






@end
